package org.example.commodity.activity;

import org.example.commodity.activity.entity.ActivityInfo;
import org.example.commodity.activity.queue.CommodityActivityMessagePushService;
import org.example.commodity.activity.queue.CommodityActivityQueueHandler;
import org.example.commodity.activity.service.BaseCommodityActivityProcessor;
import org.example.commodity.activity.service.CommodityActivityService;
import org.example.commodity.activity.util.CommodityActivityRedisUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

import java.util.List;

@Configuration
public class CommodityActivityConfiguration {
    @Bean
    @ConditionalOnMissingBean(CommodityActivityMessagePushService.class)
    public CommodityActivityMessagePushService defaultCommodityActivityMessagePushService(){
        return commodityActivityPurchaseParam -> {

        };
    }
    @Bean
    public CommodityActivityService commodityActivityService(List<BaseCommodityActivityProcessor<? extends ActivityInfo>> processors,
                                                             CommodityActivityMessagePushService pushServiceMessage){
        return new CommodityActivityService(processors, pushServiceMessage);
    }
    @Bean
    public CommodityActivityQueueHandler commodityActivityQueueHandler(CommodityActivityService commodityActivityService){
        return new CommodityActivityQueueHandler(commodityActivityService);
    }
    @Bean
    public CommodityActivityRedisUtil commodityActivityRedisUtil(StringRedisTemplate redisTemplate){
        return new CommodityActivityRedisUtil(redisTemplate);
    }
}
